﻿<Window xmlns="https://github.com/avaloniaui"
        xmlns:b="clr-namespace:Dialogs.Buttons;assembly=Dialogs.Avalonia"
        xmlns:c="clr-namespace:Dialogs.Controls;assembly=Dialogs.Avalonia"
        xmlns:d="clr-namespace:Dialogs.Avalonia;assembly=Dialogs.Avalonia"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Design.DataContext="{x:Static d:Designer.Dialog}"
        x:Class="AM.Avalonia.Dialogs.DialogWindow"
        SizeToContent="WidthAndHeight"
        WindowStartupLocation="CenterOwner"
        Title="{Binding Title}">
  <Window.DataTemplates>
    <DataTemplate DataType="{x:Type b:Button}">
      <Button Content="{Binding Name}"
              Command="{Binding}"
              IsDefault="{Binding IsDefault}"
              IsVisible="{Binding IsVisible}"
              IsEnabled="{Binding IsEnabled}"
              Margin="5"/>
    </DataTemplate>
    <DataTemplate DataType="{x:Type c:StringControl}">
      <Grid ColumnDefinitions="*,Auto,2*" Margin="10">
        <TextBlock Grid.Column="0" Text="{Binding Name}" VerticalAlignment="Center"/>
        <TextBlock Grid.Column="1" Text="*" IsVisible="{Binding IsRequired}" Foreground="Red"/>
        <TextBox Grid.Column="2" Text="{Binding Value}"/>
      </Grid>
    </DataTemplate>
    <DataTemplate DataType="{x:Type c:BoolControl}">
      <CheckBox Margin="10" IsChecked="{Binding Value}" Content="{Binding Name}"/>
    </DataTemplate>
    <DataTemplate DataType="{x:Type c:ProgressControl}">
      <ProgressBar Margin="10" Value="{Binding Value}" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}"/>
    </DataTemplate>
  </Window.DataTemplates>
  <Grid RowDefinitions="Auto,*,Auto">
    <TextBlock Grid.Row="0"
               Text="{Binding Description}"
               Margin="10"/>
    <ItemsControl Grid.Row="1" Items="{Binding Controls}"/>
    <ItemsControl Grid.Row="2"
                  HorizontalAlignment="Right"
                  Items="{Binding Buttons}">
      <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
          <StackPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
      </ItemsControl.ItemsPanel>
    </ItemsControl>
  </Grid>
</Window>
